package com.panghl.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.panghl.mapper.ProductsMapper;
import com.panghl.model.entity.Products;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xiaokuixiao
 * date2024/7/25 14:40
 */
@RequestMapping("/products")
@RestController
public class ProductsController {

    @Resource
    private ProductsMapper productMapper;


    @PostMapping("/insert")
    public String insert(@RequestBody Products products) {
        productMapper.insert(products);
        return "ok";
    }

    @PostMapping("/list")
    public List<Products> list() {
        return  productMapper.selectList(new QueryWrapper<Products>());
    }

}
